<template>
  <div class="tanchuangbg" v-show="showTag" @click="toggleShow" style="display: none;" >
    <!-- 中奖名单 -->
    <div class="win-list-cont" @click.stop>
      <div class="rab_title">{{$t('carGame.win_list')}}
        <i @click="toggleShow" class="iconfont icon-guanbi" ></i>
      </div>
      <div class="win-head-bar">
        <span>{{$t('carGame.user_name')}}</span>
        <span>{{$t('carGame.amount')}}</span>
        <span>{{$t('carGame.num')}}</span>
      </div>
      <ul class="win-list">
        <!--<li v-for="item in userList" v-bind:key="item.id">-->
          <!--<span>{{item.user}}</span>-->
          <!--<span>{{item.reward}}</span>-->
          <!--<span>{{item.digital}}</span>-->
        <!--</li>-->
        <!--<li v-show="userList.length === 0">-->
          <!--<div style="text-align: center;line-height: 60px;">没有数据</div>-->
        <!--</li>-->
        <li v-for="item in userList" v-bind:key="item.id" class="win-list-cell">
          <span>{{item.user}}</span>
          <span>{{item.reward}}</span>
          <span>{{item.digital}}</span>
        </li>
        <li v-show="userList.length === 0">
          <div style="text-align: center;line-height: 60px;color: #fff;font-size: 14px;">{{$t('carGame.no_record')}}</div>
        </li>
        <li v-show="userList[0] == '000'">
          <div style="text-align: center;line-height: 60px;color: #fff;">loading...</div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data: function () {
    return {
      showTag: false,
      userList: []
    }
  },
  props: ['gameId'],
  watch: {
    gameId (val) {
      this.userList = ['000']
      this.getData(val)
    }
  },
  methods: {
    toggleShow () {
      this.showTag = !this.showTag
    },
    gameMongodb (url, json, callback) {
      const axios = require('axios')
      axios.post(this.$config.gameMongodbApiUrl + '/cargame/' + url, json).then(function (response) {
        callback(response.data)
      }).catch(function (error) {
        console.log(error)
      })
    },
    async getData () {
      this.gameMongodb('getBetList', {gameid: this.gameId, limit: 1000}, data => {
        this.userList = data.data.filter(item => item.reward.indexOf('0.0000') < 0)
        console.log(this.userList)
      })
    }
  }
}
</script>

<style></style>
